<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Sning 文件下载</title>
<meta name="keywords" content="个人博客,Sning个人博客,宋高明" />
<meta name="description" content="Sning个人博客，学无止境，勇于探索。" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="static/css/base.css" rel="stylesheet">
<link href="static/css/index.css" rel="stylesheet">
<link href="static/css/m.css" rel="stylesheet">
<!--[if lt IE 9]>
<script src="js/modernizr.js"></script>
<![endif]-->
</head>
<body>
<header>
  <div id="mnav">
    <div class="logo"><a href="/">Sning个人博客</a></div>
    <h2 id="mnavh"><span class="navicon"></span></h2>
    <ul id="starlist">
        <li><a href="index.html">首页</a></li>
        <li><a href="blog_list=9900.html">博客</a></li>
        <li><a href="write.html">写作</a></li>
        <li><a href="share.html">项目</a></li>
        <li><a href="file.html">文件</a></li>
        <li><a href="about.html">关于</a></li>
    </ul>
  </div>
<script>
window.onload = function ()
{
  var oH2 = document.getElementById("mnavh");
  var oUl = document.getElementById("starlist");
  oH2.onclick = function ()
  {
    var style = oUl.style;
    style.display = style.display == "block" ? "none" : "block";
    oH2.className = style.display == "block" ? "open" : ""
  }
var obj=null;
var As=document.getElementById('starlist').getElementsByTagName('a');
obj = As[0];
for(i=1;i<As.length;i++){if(window.location.href.indexOf(As[i].href)>=0)
obj=As[i];}
obj.id='selected'
}
</script>
</header>
<body>
<article>
  <h1 class="t_nav"><span>好咖啡要和朋友一起品尝，好项目也要和同样喜欢它的人一起分享。 </span><a href="/" class="n1">首 页</a><a href="/file.html" class="n2">文件传输</a></h1>
    <div class="infos">
        <div class="filelist">
            <h2 class="hometitle">文件下载</h2>
            <ol id="file">
            {% for file in list %}
            <li  >
            <a style="text-decoration:none;color: #000000;" href="static/file/{{file}}" download="{{file}}">
            {{file}}</a>
            </li>
            {% end %}
            </ol>
        </div>
    </div>

    <div class="sidebar">
        <div class="paihang">
            <h2 class="hometitle">文件上传</h2>
            <form class="upfile" id ="upfile">
            <input id="up_file" type='file' name='file'/><br /><br />
            </form>
            <button  class="btn_fun" onclick="submitfile()">上传 </button>
        </div>
    </div>
</article>
<div   style="height:350px">

</div>
<footer>
  <p>Design by <a href="/">Sning</a> 
  <a href="http://www.yangqq.com" target="_blank">模板来自：杨青个人博客</a>
  </p>
</footer>
<script type="text/javascript">
    function submitfile() {  
        var up_file=document.getElementById('up_file')
        if(up_file.value==''){
          alert("未选择文件")
          return
        }
        var form =document.getElementById("upfile")
        var formdata = new FormData(form);
        var xhr=new XMLHttpRequest();
          xhr.open("post","file");
          xhr.send(formdata);
          xhr.onload=function(){
              if(xhr.status==200){
                alert("文件上传成功，请刷新页面")
              }
              if(xhr.status==201){
                alert("error")
              }
          }
    }
</script>
</body>
</html>